#pragma once
#include "ICamera.h"

#include <Irrlicht.h>

/**
    Irrlicht Implementation of a Camera
*/
class IrrCamera : public ICamera
{
public:
    IrrCamera(void);

    /** Initialize the camera */
    bool Init();

    /** Update the camera to another location if needed */
	void Update(float dt);

    /** Point the camera at a location */
    void LookAt( const MVector3f &pos );
    /** Move the Camera over time to this new location, multiplied by the speed var */
    void MoveTo( const MVector3f &dest );
    /** Shake the camera for a duration and a velocity */
    void Shake( float time, float magnitude );

    /** Test to see if this rectangle intersects with the viewport */
    bool Contains( const MAABBox3f &r  ); 
    /** Test to see if this point intersects with the viewport */
    bool Contains( const MVector3f &v );

    /** Get the Position of the camera (world relative) */
    MMatrix4x4f GetProjectionMat() const; 
    /** Sets the new position, also recalculates the viewport properly */
    void SetProjectionMat( const MMatrix4x4f &m ); 

    /** Set the up vector */
    void SetUpVector( const MVector3f &v );
    MVector3f GetUpVector() const;

    /** Set the FOV */
    void SetFOV ( float f );
    float GetFOV() const;

    /** Set the aspect ration */
    void SetAspectRatio( float f );
    float GetAspectRation() const;

    /** Set the dimensions of the camera */
    void SetFrustum(const MFrustum &f );
    const MFrustum* GetFrustum() const;

    /** Set to be the main camera */
    void SetMainCamera();

    /** Get the Irrlicht Camera */
    irr::scene::ICameraSceneNode* GetCamera() { return m_IrrCamera; };

private:
    irr::scene::ICameraSceneNode*   m_IrrCamera;
    irr::scene::ISceneManager*      m_IrrSceneMng;
public:
    virtual ~IrrCamera(void);
};
